#include <iostream>
#include <string>
using namespace std;

//试验初始化列表，对类中属性对象初始化的影响
//一步完成

class Car
{
public:
	Car()
	{
		cout << this << endl;
		cout << "Car 默认构造函数调用" << endl;
	}
	Car(const Car& x)
	{
		cout << this << endl;
		cout << "Car 拷贝构造函数的调用" << endl;
	}
	~Car()
	{
		cout << this << endl;
		cout << "Car 析构函数的调用" << endl;	
	}
	
private:
	string m_name;
	string m_num;
};

class Person
{
public:
	Person(Car x): m_a(x)
	{
		cout << this << endl;
		cout << "m_a" << &this->m_a << endl;
		cout << "Person 有参构造函数调用" << endl;
	}
	Person()
	{
		cout << this << endl;
		cout << "Person 默认构造函数调用" << endl;
	}
	Person(int age)
	{
		m_age = age;
		cout << this << endl;
		cout << "Person 有参构造函数调用" << endl;
	}
	//拷贝构造函数的传参为什么必须是对象的引用，防止死循环
	Person(const Person& x)
	{
		m_age = x.m_age;
		cout << this << endl;
		cout << "Person 拷贝构造函数调用" << endl;
	}
	~Person()
	{
		cout << this << endl;
		cout << "Person 析构函数的调用" << endl;
	}
	
private:
	Car m_a;
	int m_age;
};


int main()
{
	cout << "初始化列表" << endl;
	Car x;
	Person Carl(x); 
	
	return 0;
}
